﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DataIntegrityChecker.Data
{
    class EqualityConstraint: IDataConstraint
    {
        private int columnToBeEqual;

        public EqualityConstraint(int columnToBeEqual)
        {
            this.columnToBeEqual = columnToBeEqual;
        }

        public int ColumnToBeEqual
        {
            get { return columnToBeEqual; }
            set { columnToBeEqual = value; }
        }

        public bool IsConstraintMet(DataRow row1, DataRow row2)
        {
            if (row1.Values.Length > columnToBeEqual && row2.Values.Length > columnToBeEqual)
            {
                return row1.Values[columnToBeEqual].Equals(row2.Values[columnToBeEqual]);
            }
            else return false;
        }
    }
}
